package com.oreilly.ez.fileserver;

import com.oreilly.ez.fileserver.impl.AddRule;
import com.oreilly.ez.fileserver.impl.SubstractRule;

import java.util.ArrayList;
import java.util.List;

public class RuleEngine {

    private static List<IRule> ruleList = new ArrayList<>();

    static{
        ruleList.add(new AddRule());
        ruleList.add(new SubstractRule());
    }


    public static Result handle(Exp exp){

        for (IRule rule : ruleList) {
            if(rule.canDo(exp)){
                Result result = rule.doIt(exp);
                return result;
            }
        }

        return null;
    }
}
